package pref.junx.flybird.fragment.daily.event;

import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.PopupMenu;
import android.support.v7.widget.RecyclerView;
import android.view.MenuItem;
import android.view.View;

import java.util.ArrayList;
import java.util.List;

import pref.junx.flybird.R;
import pref.junx.flybird.adapter.SimpleAdapter;
import pref.junx.flybird.base.BaseFragment;
import pref.junx.flybird.entity.Event;


/**
 * Created by acer on 2017/8/4.
 */

public class DailyFragment extends BaseFragment<DailyPresenter, DailyModlel> implements DailyContract.View, PopupMenu.OnMenuItemClickListener {

    private List data = new ArrayList<Event>();

    RecyclerView recyclerView;

    private SimpleAdapter adapter;

    private DefaultItemAnimator animator;

    public List<Event> eventList=new ArrayList<>();
    @Override
    public int getLayoutId() {
        return R.layout.fragment;
    }

    @Override
    public void initView() {
        initdata();


    }



    @Override
    protected void init() {
        String a=spTools.getString("");
//     presenter.getEvent(spTools.getString("user_id"));

    }
   void initdata(){
       presenter.getEvent(spTools.getInt("user_id"));

   }


    @Override
    public void reportsuccess(String a, int b) {


    }

    @Override
    public void reportfail(String a) {
        ts.show_l("上报失败");
    }

    @Override
    public void itmeSelect(String i, String n) {

    }

    @Override
    public void setEvents(List<Event> data) {
        eventList=data;
        recyclerView=(RecyclerView) getView().findViewById(R.id.recyclerview);
        recyclerView.setHasFixedSize(true);
        recyclerView.setItemAnimator(animator);
        recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
        adapter = new SimpleAdapter(getActivity(), eventList);
        recyclerView.setAdapter(adapter);
    }


    @Override
    public void onClick(View v) {


    }


    @Override
    public boolean onMenuItemClick(MenuItem item) {
        return false;
    }
}
